<%--
  Created by IntelliJ IDEA.
  User: 86188
  Date: 2019/1/18
  Time: 10:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>全部贷款信息</title>
    <script src="/static/js/jquery-3.3.1.js"></script>
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
    <script src="/static/layuiadmin/layui/layui.js" type="text/javascript"></script>
    <style>
        body {
            margin: 10px;
        }
    </style>
</head>
<body>
<div style="position: fixed;left: 200px">
    <input id="caddress" name="caddress" type="text" class="layui-input" placeholder="请输入地址" value="">
</div>
<div style="position: fixed;left: 384px">
    <input id="cletters" name="cletters" type="text" class="layui-input" placeholder="请输入授信机构" value="">
</div>
<div style="position: fixed;left: 573px">
    <input id="cproduct" name="cproduct" type="text" class="layui-input" placeholder="请输入产品" value="">
</div>
<div class="layui-inline">
    <input id="cname" name="cname" type="text" class="layui-input" placeholder="请输入申请人姓名" value="">
</div>
<div style="position: fixed;left: 800px;top: 11px;">
    <button id="sea" class="layui-btn layui-btn-normal" data-type="reload" onclick="sear()">查询</button>
</div>

<table class="layui-hide" id="demo" lay-filter="test"></table>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">查看</a>
</script>
<script>
    layui.use('table', function () {
        var params = {
            cname: $('#cname').val(),
            caddress: $('#caddress').val(),
            cletters: $('#cletters').val(),
            cproduct: $('#cproduct').val(),
            cstate: ""
        };
        var table = layui.table;
        //执行一个 table 实例
        table.render({
            elem: '#demo',
            url: 'getCreditList?name=' + encodeURIComponent(JSON.stringify(params)),   //数据接口,
            title: '',
            page: true,
            limit: 10,
            limits: [10, 20, 30, 40, 50],
            cols: [[ //表头
                {type: 'checkbox', fixed: 'left', align: 'center'}
                , {field: 'cpipeline', title: '申请流水号', align: 'center', width: 200}
                , {field: 'ctime', title: '时间', align: 'center', width: 200}
                , {field: 'cname', title: '申请人姓名', sort: true, align: 'center'}
                , {field: 'cphone', title: '联系电话', align: 'center'}
                , {
                    field: 'cdocumenttype', title: '证件类型', align: 'center',
                    templet: function (c) {
                        if (c.cdocumenttype == 1) {
                            return "身份证";
                        } else if (c.cdocumenttype == 2) {
                            return "护照";
                        } else if (c.cdocumenttype == 3) {
                            return "港澳居民身份证";
                        } else if (c.cdocumenttype == 4) {
                            return "香港身份证";
                        }
                    }
                }
                , {field: 'cidentificationnumber', title: '证件号', align: 'center'}
                , {field: 'cmoney', title: '申报金额', align: 'center', sort: true}
                , {field: 'caddress', title: '地址', align: 'center'}
                , {field: 'cclaims', title: '债权包', align: 'center'}
                , {field: 'cmechanism', title: '所属机构', align: 'center'}
                , {field: 'cfa', title: 'FA', align: 'center'}
                , {field: 'cletters', title: '授信机构', align: 'center'}
                , {field: 'cproduct', title: '产品', align: 'center'}
                , {
                    field: 'cstate', title: '发布状态', align: 'center',
                    templet: function (s) {
                        if (s.cstate == 1) {
                            return "待初审";
                        } else if (s.cstate == 2) {
                            return "待调研";
                        } else if (s.cstate == 3) {
                            return "待复审";
                        } else if (s.cstate == 4) {
                            return "待授信";
                        } else if (s.cstate == 5) {
                            return "授信成功";
                        } else if (s.cstate == 6) {
                            return "授信失败";
                        }
                    }
                }
                , {fixed: 'right', title: '操作', width: 100, align: 'center', toolbar: '#barDemo'}
            ]]
            , id: "reload"
        });
    });

    //查询方法
    function sear() {
        var params = {
            cname: $('#cname').val(),
            caddress: $('#caddress').val(),
            cletters: $('#cletters').val(),
            cproduct: $('#cproduct').val(),
            cstate: ""
        };
        layui.use(['laypage', 'layer', 'table'], function () {
            var laydate = layui.laydate //日期
                , laypage = layui.laypage //分页
                , table = layui.table; //表格
            table.reload('reload', {
                url: 'getCreditList?name=' + encodeURIComponent(JSON.stringify(params)) //数据接口
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });
    }

    layui.use(['form', 'laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element', 'slider'], function () {
        var laydate = layui.laydate //日期
            , laypage = layui.laypage //分页
            , layer = layui.layer //弹层
            , table = layui.table //表格
            , carousel = layui.carousel //轮播
            , upload = layui.upload //上传
            , element = layui.element //元素操作
            , slider = layui.slider //滑块

        //监听行工具事件
        table.on('tool(test)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data //获得当前行数据
                , layEvent = obj.event; //获得 lay-event 对应的值
            if (layEvent === 'edit') {
                layer.msg(obj.data.cid);
                layer.open({
                    type: 2,
                    title: '查看全部贷款信息',
                    maxmin: true,
                    shadeColse: true,//点击遮罩关闭层
                    area: ['1000px', '540px'],
                    content: 'selectCreditCid?cid=' + obj.data.cid + '&cstate=' + obj.data.cstate,
                    end: function () {
                        //关闭窗口
                        table.reload('reload', {
                            page: {
                                curr: 1 //重新从第 1 页开始
                            }
                        });
                    }
                });
            }
        });
    });
</script>
</body>
</html>